<template>
  <div class="xiecheng">
    <div class="admin_main_block">
      <div class="admin_main_block_select">

        <div class="input">
          <el-input v-model="dataForm.chinese_name" :placeholder="$t('common.please_input') + $t('business.shipowner.chinese_name')" clearable>
          </el-input>
        </div>
        <div class="input">
          <el-input v-model="dataForm.english_name" :placeholder="$t('common.please_input') + $t('business.shipowner.english_name')" clearable>
          </el-input>
        </div>
        <div class="input">
          <el-button icon="Search" @click="getDataList(true)">
            {{ i18n('common.search') }}
          </el-button>
        </div>
      </div>

      <div class="admin_table_main">
        <el-table :data="dataList" v-loading="dataListLoading" @selection-change="selectionChangeHandle" stripe>
          <el-table-column type="selection" header-align="center" align="center">
          </el-table-column>

          <el-table-column prop="id" :label="i18n('common.id')" width="70px">
          </el-table-column>

          <el-table-column prop="logo" :label="i18n('business.shipowner.logo')" width="90">
            <template v-slot="scope">
              <el-image class="cx-list-image" :src="scope.row.logo">
                <template v-slot:error>
                  <div class="image-slot">
                    <el-icon><Picture /></el-icon>
                  </div>
                </template>
              </el-image>
            </template>
          </el-table-column>

          <el-table-column prop="chinese_name" :label="i18n('business.shipowner.chinese_name')" min-width="140">
          </el-table-column>

          <el-table-column prop="english_name" :label="i18n('business.shipowner.english_name')" min-width="180">
          </el-table-column>

          <el-table-column :label="i18n('common.handle')" fixed="right" width="150">
            <template v-slot="scope">
              <el-button
                v-if="isAuth('module:business:publish:template:list')"
                icon="Files"
                @click="router.push({ name: 'module_business_publish_template_list', query: { shipowner_id: scope.row.id } })">
                {{ i18n('business.publish.template.info') }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="admin_table_main_pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :page-size="pageSize"
            :total="totalPage"
            :current-page="pageIndex"
            background
            layout="prev, pager, next,jumper,total">
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup name="business-publish-list">
  import { useBase } from "@/hooks/base/useBase"
  import { useTable } from "@/hooks/table/useTable"

  const { router, i18n, isAuth } = useBase()

  const model = ref('business/shipowner')

  const dataForm = reactive([
    'chinese_name',
    'english_name',
  ])

  const {
    dataList,
    pageIndex,
    pageSize,
    totalPage,
    dataListLoading,
    sizeChangeHandle,
    currentChangeHandle,
    selectionChangeHandle,
    getDataList,
    handleStatus,
    deleteHandle,
  } = useTable(model.value, dataForm)

  onMounted(() => {
    getDataList(model)
  })
</script>
